import Vue from 'vue'
import App from './App.vue'
import router from './router'

// 引入Element-UI
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
Vue.use(ElementUI);
// 导入vuex
import store from './store'

// 配置axios全局变量
import axios from 'axios'
axios.interceptors.request.use(
  config => {
    let token = localStorage.getItem("token");
    if (token) {
      config.headers.token = token;
    }
    // 确保在所有情况下都返回 config 对象
    return config;
  },
  error => {
    // 处理请求错误
    return Promise.reject(error);
  }
);

Vue.prototype.$axios = axios

Vue.config.productionTip = false

new Vue({
  // 配置全局方法
  beforeCreate () {
    Vue.prototype.$bus = this
  },
  // 路由
  router,
  // vuex配置
  store,
  render: h => h(App)
}).$mount('#app')
